package Demo;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * @author げっしょく
 * @date 2021/7/27
 */
public class HashMap1 {
    public static void main(String[] args) {
        HashMap<HashStudent,String> hs = new HashMap<>();
        HashStudent stu1 = new HashStudent("zhangsan", 24);
        HashStudent stu2 = new HashStudent("lisi", 27);
        HashStudent stu3 = new HashStudent("wangwu", 20);
        HashStudent stu4 = new HashStudent("zhaoliu", 21);
        HashStudent stu5 = new HashStudent("wangwu", 20);
        hs.put(stu1, "hunan");
        hs.put(stu2, "shanghai");
        hs.put(stu3, "beijing");
        hs.put(stu4, "guangdong");
        hs.put(stu5, "shaoyang");
        Set<HashStudent> hashStudents = hs.keySet();
        Iterator<HashStudent> iterator = hashStudents.iterator();
        while (iterator.hasNext()) {
            HashStudent next = iterator.next();
            String s = hs.get(next);
            System.out.println(next + "-----" + s);
        }
        System.out.println("///////////////////////////////////////////////////");
        Set<Map.Entry<HashStudent, String>> entries = hs.entrySet();
        for (Map.Entry<HashStudent, String> entry : entries) {
            System.out.println(entry.getKey() + "=========" + entry.getValue());
        }

    }
}
